package com.weiaibenpao.demo.chislim.ui.adapter;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.weiaibenpao.demo.chislim.R;
import com.weiaibenpao.demo.chislim.bean.MarathonBean;
import com.weiaibenpao.demo.chislim.utils.Utils;

/**
 * Created by wlx on 2018/1/8.
 */

public class MyMarathonListAdapter extends BaseQuickAdapter<MarathonBean.MarathoListBean,BaseViewHolder> {
    public MyMarathonListAdapter() {
        super(R.layout.marathon_list_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, MarathonBean.MarathoListBean item) {
            helper.setText(R.id.tv_marathon_title,item.getMarathonTitle())//yyyy-MM-dd
                    .setText(R.id.tv_remainTime,"活动日期："+ Utils.getFormattedTime(item.getSportsStartTime(),"yyyy年MM月dd日")
                            +"-"+Utils.getFormattedTime(item.getSportsEndTime(),"yyyy年MM月dd日"));
            helper.getView(R.id.tv_joinNumber).setVisibility(View.GONE);

        Glide.with(mContext).load(item.getMContentImg()).into((ImageView) helper.getView(R.id.img_marathon));
        helper.getView(R.id.img_match_status).setVisibility(View.VISIBLE);
        if (item.getMarathonTimeStatus()==0){
            Glide.with(mContext).load(R.drawable.event_startsoon).into((ImageView) helper.getView(R.id.img_match_status));
        }else  if (item.getMarathonTimeStatus()==1){
            Glide.with(mContext).load(R.drawable.event_startalready).into((ImageView) helper.getView(R.id.img_match_status));
        }else  if (item.getMarathonTimeStatus()==2){
            Glide.with(mContext).load(R.drawable.event_end).into((ImageView) helper.getView(R.id.img_match_status));
        }
    }
}
